package com.yy.base.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;

public class FileUtil {
	public String readFileText(String path) throws Exception {
		BufferedReader br = null;
		StringBuilder text = new StringBuilder();
		try {
			File file = new File(path);
			br = new BufferedReader(new FileReader(file));
			String str = null;
			while ((str = br.readLine()) != null) {
				text.append(str);
				text.append("\r\n");
			}
		} finally {
			try {
				br.close();
			} catch (Exception e) {
			}
		}
		return text.toString();
	}
	/**
	 * 写入文件类容
	 */
	public void writeFileText(String data, String filePath) throws Exception {
		FileWriter writer = null;
		try {
			writer = new FileWriter(filePath, true);
			writer.append(data);
		} finally {
			try {
				writer.close();
			} catch (Exception e) {
			}
		}
	}
}